﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using An_Im.Extension.Contract;
namespace An_Im.Extension
{
    /// <summary>
    /// 插件宿主。
    /// </summary>
    static class ExtensionLoader
    {
        /// <summary>
        /// 载入并创建 MEF 宿主。
        /// </summary>
        /// <returns></returns>
        public static ExtensionHost Load()
        {
            var host = new ExtensionHost();
            var catalog = new DirectoryCatalog(CoreManipulator.AddInStorePath);

            // 加载用于连接的容器。
            var container = new CompositionContainer(catalog);

            // 将宿主与插件集合在容器中连接。
            container.ComposeParts(host);

            return host;
        }

    }


}
